package com.ourteam.product.model.api;

import org.apache.commons.lang3.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.model.dao.ProductModelDomainDAOQueryBean;
import com.ourteam.product.model.domain.ProductModelDomainBean;

public class ProductModelDomainSearchModel extends AbstractSearchModel<ProductModelDomainDAOQueryBean> {

	private String domainName;

	private String domainCode;

	public String getDomainName() {
		return domainName;
	}

	public void setDomainName(String domainName) {
		this.domainName = domainName;
	}

	public String getDomainCode() {
		return domainCode;
	}

	public void setDomainCode(String domainCode) {
		this.domainCode = domainCode;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductModelDomainBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductModelDomainDAOQueryBean queryBean) throws Exception {

		ProductModelDomainDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (StringUtils.isNotBlank(domainName)) {
			criteria.andDomainNameLike(domainName);
		}

		if (StringUtils.isNotBlank(domainCode)) {
			criteria.andDomainCodeLike(domainCode);
		}

	}

}
